
package com.insigma.business.qrcode.common.converter;

import com.insigma.business.qrcode.common.dto.CommonFavoriteBSearcher;
import com.insigma.business.qrcode.common.dto.CommonFavoriteDO;
import com.insigma.business.qrcode.common.dto.CommonFavoriteSearchRequest;
import com.insigma.business.qrcode.common.dto.CommonFavoriteUpdateRequest;
import com.insigma.business.qrcode.pay.dto.CommonFavoriteInsertRequest;
import com.insigma.business.qrcode.welfare.dto.CommonFavoriteDTO;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CommonFavoriteProviderConverter extends AbstractConverter<CommonFavoriteDTO, CommonFavoriteDO> {

    private final static CommonFavoriteProviderConverter commonFavoriteConverter = new CommonFavoriteProviderConverter();

    private CommonFavoriteProviderConverter(){}

    
    public static CommonFavoriteBSearcher convertRequestSO2Searcher(final CommonFavoriteSearchRequest request){
        final CommonFavoriteBSearcher commonFavoriteBSearcher = new CommonFavoriteBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,commonFavoriteBSearcher);
        return commonFavoriteBSearcher;
    }

    
    public static CommonFavoriteDO convertRequestUO2DO(final CommonFavoriteUpdateRequest commonFavoriteUpdateRequest) {
        final CommonFavoriteDO commonFavoriteDO = new CommonFavoriteDO();
        BeanUtils.copyProperties(commonFavoriteUpdateRequest,commonFavoriteDO);
        
        return commonFavoriteDO;
    }

    
    public static CommonFavoriteDO convertRequestIO2DO(final CommonFavoriteInsertRequest commonFavoriteInsertRequest) {
        final CommonFavoriteDO commonFavoriteDO = new CommonFavoriteDO();
        BeanUtils.copyProperties(commonFavoriteInsertRequest,commonFavoriteDO);
        return commonFavoriteDO;
    }

    
    public static List<CommonFavoriteDTO> convertResponseDOList2DTOList(final List<CommonFavoriteDO> commonFavoriteDOList){
        return commonFavoriteConverter.convertGenericResponseDOList2DTOList(commonFavoriteDOList);
    }

    
    public static CommonFavoriteDTO convertResponseDO2DTO(final CommonFavoriteDO commonFavoriteDO){
        return commonFavoriteConverter.convertGenericResponseDO2DTO(commonFavoriteDO);
    }

    
    @Override
    protected CommonFavoriteDTO doConvertResponseDO2DTO(CommonFavoriteDO commonFavoriteDO) {
        final CommonFavoriteDTO commonFavoriteDTO = new CommonFavoriteDTO();
        try {
            BeanUtils.copyProperties(commonFavoriteDO, commonFavoriteDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return commonFavoriteDTO;
    }

}
